Skip to content

Handle DAC conversion when using weight_norm with newer PyTorch versions#36393

Merged
vasqu merged 4 commits intohuggingface:mainfrom
edwko:main
Jul 10, 2025
Merged

Handle DAC conversion when using weight_norm with newer PyTorch versions#36393
vasqu merged 4 commits intohuggingface:mainfrom
edwko:main

Conversation

@edwko
Copy link
Contributor

@edwko edwko commented Feb 25, 2025

What does this PR do?

nn.utils.weight_norm has been moved to nn.utils.parametrizations.weight_norm. As a result, parametrized layers no longer expose weight_g or weight_v, but only weight. This causes an AttributeError when DAC conversion attempts to access weights:

AttributeError: 'ParametrizedConv1d' object has no attribute 'weight_g'. Did you mean: 'weight'?

This PR moves apply_weight_norm directly into the script, explicitly setting to use weight_norm = nn.utils.weight_norm to ensure compatibility.

@xenova
Copy link
Contributor

xenova commented Feb 25, 2025

cc @kamilakesbi, who made the original conversions (do they still work with the existing conversion scripts?)

@xenova
Copy link
Contributor

xenova commented Mar 1, 2025

Maybe related to #33275? cc @ylacombe

@edwko
Copy link
Contributor Author

edwko commented Mar 2, 2025

Maybe related to #33275? cc @ylacombe

Yes, that PR updates several models including modeling_dac.py to use nn.utils.parametrizations.weight_norm for newer torch versions. However, the DAC script still expects the deprecated weight normalization, causing it to fail.

Copy link
Contributor

@vasqu vasqu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review, this is indeed needed! We also discovered this in #39313 and somehow this PR slipped through :/

A bit unhappy that we have to use a deprecated function but it's kinda forced based on the original weights.

@vasqu
Copy link
Contributor

vasqu commented Jul 10, 2025

@bot /style

@github-actions
Copy link
Contributor

github-actions bot commented Jul 10, 2025

Style bot fixed some files and pushed the changes.

@github-actions
Copy link
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: dac

@vasqu vasqu enabled auto-merge (squash) July 10, 2025 10:24
@vasqu vasqu merged commit 6b09c8e into huggingface:main Jul 10, 2025
15 checks passed
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

rjgleaton pushed a commit to rjgleaton/transformers that referenced this pull request Jul 17, 2025
…ons (huggingface#36393)

* Update convert_dac_checkpoint.py

* Update convert_dac_checkpoint.py

* Apply style fixes

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Anton Vlasjuk <73884904+vasqu@users.noreply.github.com>
zaristei pushed a commit to zaristei/transformers that referenced this pull request Sep 9, 2025
…ons (huggingface#36393)

* Update convert_dac_checkpoint.py

* Update convert_dac_checkpoint.py

* Apply style fixes

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Anton Vlasjuk <73884904+vasqu@users.noreply.github.com>
zaristei pushed a commit to zaristei/transformers that referenced this pull request Sep 9, 2025
…ons (huggingface#36393)

* Update convert_dac_checkpoint.py

* Update convert_dac_checkpoint.py

* Apply style fixes

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Anton Vlasjuk <73884904+vasqu@users.noreply.github.com>
zaristei pushed a commit to zaristei/transformers that referenced this pull request Sep 9, 2025
…ons (huggingface#36393)

* Update convert_dac_checkpoint.py

* Update convert_dac_checkpoint.py

* Apply style fixes

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Anton Vlasjuk <73884904+vasqu@users.noreply.github.com>
zaristei pushed a commit to zaristei/transformers that referenced this pull request Sep 9, 2025
…ons (huggingface#36393)

* Update convert_dac_checkpoint.py

* Update convert_dac_checkpoint.py

* Apply style fixes

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Anton Vlasjuk <73884904+vasqu@users.noreply.github.com>
zaristei pushed a commit to zaristei/transformers that referenced this pull request Sep 9, 2025
…ons (huggingface#36393)

* Update convert_dac_checkpoint.py

* Update convert_dac_checkpoint.py

* Apply style fixes

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Anton Vlasjuk <73884904+vasqu@users.noreply.github.com>
zaristei pushed a commit to zaristei/transformers that referenced this pull request Sep 9, 2025
…ons (huggingface#36393)

* Update convert_dac_checkpoint.py

* Update convert_dac_checkpoint.py

* Apply style fixes

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Anton Vlasjuk <73884904+vasqu@users.noreply.github.com>
zaristei pushed a commit to zaristei/transformers that referenced this pull request Sep 9, 2025
…ons (huggingface#36393)

* Update convert_dac_checkpoint.py

* Update convert_dac_checkpoint.py

* Apply style fixes

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Anton Vlasjuk <73884904+vasqu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants